package fall2014.cs343.lab2.multithreading;

/**
 * C - Simple class using the Runnable interface.
 * 
 * This class introduces basic concepts in setting up an application
 * with multiple threads. 
 * 
 */
public class C implements Runnable{
	
	private static int asset = 0;
	public static final int target = 200;

	private int data = 0;
	private String name;
	
	/**
	 * Default Constructor
	 */
	public C() {
		data = 0;
		name = "C";
	}

	/**
	 * Constructor with String param
	 * 
	 * @param name
	 */
	public C(String name) {
		this.name = name;
	}

	/**
	 * run method
	 * 
	 *  - this is where the work gets done in the thread
	 */
	public void run(){
		while (asset < target){
			work();
			asset += 10;
			System.out.println(" " + name + ": Asset is now " + asset);
		}
		System.out.println(" " + name + ": Performed " + data + " iterations.");
	}

	/**
	 * work method
	 * - increments the instance data member named "data"
	 */
	private void work(){
		data++;
	}

}
